package com.example.mydemoproject.config.exception;

import com.example.mydemoproject.model.constant.CommonConstant;
import lombok.Getter;
import lombok.Setter;

/**
 * @description: 自定义异常
 * @author: LiuZhiYong
 * @create: 2021-12-02
 **/
@Getter
@Setter
public class ServiceException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private final Integer code;

    public ServiceException(String message) {
        super(message);
        this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
    }

    public ServiceException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public ServiceException(Throwable cause) {
        super(cause);
        this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
        this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
    }
}
